<template>
  <section>
    <div class="custorm--modelbox graphicueditor-edit">
      <renohome-right-nav :custormItemData="custormItemData" @rightNavChange="rightNavChange"></renohome-right-nav>
      <div class="edit-form-item">
        <div class="form-label">颜色选择</div>
        <div class="stylebox flex-row flex-align-c ivu-color-picker"><span style="margin-right:13px;">背景</span>
          <el-color-picker
            class="ivu-input"
            v-model="custormItemData.style.bgcolor"
            size="mini"
          ></el-color-picker>
          <span class="ivu-input">{{custormItemData.style.bgcolor}}</span>
        </div>
      </div>

      <div class="edit-form-item">
        <div class="form-label">上下边距</div>
        <div class="flex-row flex-align-c">
          <el-slider
            :show-tooltip="false"
            style="width: 70%;"
            v-model="margincol"
            input-size="mini"
            :max="48"
          >
          </el-slider>
          <div class="coupon-showslider">{{custormItemData.style.margincol}}px</div>
        </div>
        <div class="form-label">左右边距</div>
        <div class="flex-row flex-align-c">
          <el-slider
            :show-tooltip="false"
            style="width: 70%;"
            v-model="marginrow"
            input-size="mini"
            :max="48"
          >
          </el-slider>
          <div class="coupon-showslider">{{custormItemData.style.marginrow}}px</div>
        </div>
      </div>

      <div
        class="edit-form-item"
        style="padding:0;"
      >
        <div class="block">
          <ueditor :ueditorChange="infoChange" :defaultMsg='infoDefault' :config='{initialFrameWidth: null,initialFrameHeight: 350}' ref="ue"></ueditor>
        </div>
      </div>
    </div>
  </section>
</template>

<script>
import ueditor from '@/components/Ueditor/index'
import defaultConfig from './utils/editConfig'
export default {
  mixins: [defaultConfig.mixins],
  data() {
    return {
      infoDefault: ''
    }
  },
  props: {
    defaultConfig: {
      type: Object,
      default: function() {
        return defaultConfig
      }
    }
  },
  created() {
    this.$nextTick(() => {
      this.infoDefault = this.custormItemData.params.ueditor
    })
  },
  components: {
    ueditor
  },
  computed: {
    margincol: {
      set(value) {
        this.custormItemData.style.margincol = value
      },
      get() {
        return this.conversionType('number', this.custormItemData.style.margincol)
      }
    },
    marginrow: {
      set(value) {
        this.custormItemData.style.marginrow = value
      },
      get() {
        return this.conversionType('number', this.custormItemData.style.marginrow)
      }
    }
  },
  methods: {
    infoChange(msg, isReady) {
      if (isReady) {
        this.custormItemData.params.ueditor = msg
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.custorm--modelbox.graphicueditor-edit {
    /deep/ .ueditor-content{
      width: 100%;
    }
}
</style>
